package com.lx.pc.restful;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lx.pc.baidu.ueditor.ActionEnter;

@Controller
@RequestMapping(value = "/ueditor")
public class UeditorController {

	@RequestMapping("/dispatch.do")
	public void config(HttpServletRequest request, HttpServletResponse response, String action) {
		PrintWriter writer = null;
		try {
			System.out.println("--------进入上传方法-------");
			request.setCharacterEncoding("utf-8");
			response.setHeader("Content-Type" , "text/html");
			String rootPath = request.getSession().getServletContext().getRealPath("/");
			String exec = new ActionEnter(request, rootPath).exec();
			writer = response.getWriter();
			writer.write(exec);
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			IOUtils.closeQuietly(writer);
		}
	}

}
